import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description: 包含min函数的栈
 * User: wangxin
 * Date: 2024-11-23
 * Time: 22:18
 */
public class test3 {
    Stack<Integer> s1 = new Stack<>();
    Stack<Integer> s2 = new Stack<>();

    public int TOP = 10001;
    public void push(int node) {
        s1.push(node);
        if(s2.isEmpty()||s2.peek()>node){
            s2.push(node);
        }else{
            s2.push(s2.peek());
        }
    }

    public void pop() {

        s1.pop();
        s2.pop();
    }

    public int top() {

        return s1.peek();
    }

    public int min() {
        return s2.peek();
    }
}
